<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>房产模块-小区信息</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${s.base}/js/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${s.base}/css/base/base.css" media="all" /></head>
	<style type="text/css">
		.xyg-upload-item{width: 80px; height: 100px; float: left; margin-left: 10px;}
		.xyg-upload-item img{height: 80px; width: auto; max-width: 80px;}
		.xyg-upload-item .xyg-upload-item-btn{width: 80px; height: 20px; line-height: 20px;}
		.xyg-upload-item .xyg-upload-item-btn-right{float: right;}
		.xyg-upload-item span{cursor: pointer;}
	</style>
<body class="childrenBody">
<form class="layui-form">
	<input type="hidden" id="id" name="id" value="${hostItem.id}" />
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;名称</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="name" value="${hostItem.name}" placeholder="请输入名称" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;开盘时间</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="openTime" name="openTime" value="${openTime}" placeholder="请选择开盘时间" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;房屋分类</label>
		<div class="layui-input-block">
			<select class="form-control" name="hostType" lay-verify="required" id="hostType"></select>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;商品图片</label>
		<div class="layui-input-block">
			<div class="layui-upload">
				<button type="button" class="layui-btn" id="image">立即上传</button>&nbsp;&nbsp;<span style="color: red;">图片宽为750px,高为320px。<a target="_blank" href="https://tinypng.com/">立即压缩</a> </span>
				<blockquote class="layui-elem-quote layui-quote-nm" id="imageContent" style="margin-top: 10px; height: 100px;">
				</blockquote>
			</div>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;封面图</label>&nbsp;&nbsp;<span style="color: red;">图片宽为160px,高为160px。<a target="_blank" href="https://tinypng.com/">立即压缩</a> </span>
		<!--单图片开始-->
		<div class="layui-input-block cy-uploadpic-ctn" id="coverImage"  style=" float:left;margin:10px 0!important;position:relative; width: 90px; height: 90px;">
		</div>
		<!--单图片结束-->
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;均价</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" id="price" name="price" value="${hostItem.price}" placeholder="请输入均价（元/平方）" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;户型面积</label>
		<div class="layui-input-block">
			<div class="layui-input-inline" style="width: 100px;">
				<input type="number" id="minApartmentArea" name="minApartmentArea" placeholder="最小面积" value="${hostItem.minApartmentArea}"  autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid">-</div>
			<div class="layui-input-inline" style="width: 100px;">
				<input type="number" id="maxApartmentArea" name="maxApartmentArea" placeholder="最大面积" value="${hostItem.maxApartmentArea}" autocomplete="off" class="layui-input">
			</div>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;总价（万）</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" id="allPrice" name="allPrice" value="${hostItem.allPrice}" placeholder="请输入总价（元）" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;户型</label>
		<div class="layui-input-block">
			<div class="layui-input-inline" style="width: 100px;">
				<input type="number" name="minRooms" placeholder="最小户型" value="${hostItem.minRooms}"  autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid">-</div>
			<div class="layui-input-inline" style="width: 100px;">
				<input type="number" name="maxRooms" placeholder="最大户型" value="${hostItem.maxRooms}" autocomplete="off" class="layui-input">
			</div>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;所属区域</label>
		<div class="layui-input-block">
			<input type="hidden" name="areaId" id="areaId" value="${hostItem.areaId}" />
			<input type="text" class="layui-input" name="areaName" id="areaName" value="${hostItem.areaName}" placeholder="请选择所属区域" lay-verify="required" autocomplete="off" />
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;详细地址</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="address" value="${hostItem.address}" placeholder="请输入详细地址" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;装修标准</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="decoration" lay-verify="content" placeholder="请输入装修标准">${hostItem.decoration}</textarea>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;产权年限</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="propertyYear" value="${hostItem.propertyYear}" placeholder="请输入产权年限" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;开发商</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="developer" value="${hostItem.developer}" placeholder="请输入开发商" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;楼盘特色</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="feature" value="${hostItem.feature}" placeholder="请输入楼盘特色" lay-verify="required" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;标签</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="tag" value="${hostItem.tag}" placeholder="请输入标签，多个用','隔开" autocomplete="off" /></div>
	</div>
	<input type="hidden" class="layui-input" name="shareType" value="1" />
	<!--<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;分销状态</label>
		<div class="layui-input-block">
			<select class="form-control" lay-filter="shareType" name="shareType" lay-verify="required" id="shareType"></select>
		</div>
	</div>-->
	<div class="layui-form-item layui-row layui-col-xs12 fx">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;佣金描述</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="shareMoney" maxlength="500" value="${hostItem.shareMoney}" placeholder="请输入佣金描述" lay-verify="required" autocomplete="off" /></div>
	</div>
	<!--<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;负责人</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="userId" value="${hostItem.userId}" placeholder="请输入负责人" autocomplete="off" /></div>
	</div>-->
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;描述</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="description" lay-verify="content" placeholder="请输入栏目描述">${hostItem.description}</textarea></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;内容</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="content" id="content" placeholder="请输入内容">${hostItem.content}</textarea></div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;热卖新房</label>
		<div class="layui-input-block">
			<select class="form-control" name="hotSaleState" lay-verify="required" id="hotSaleState"></select>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;经纬度</label>
		<div class="layui-input-block">
			<div class="layui-input-inline" style="width: 200px;">
				<input type="text" class="layui-input" name="longitude" value="${hostItem.longitude}" placeholder="请输入经度(180到-180)"  autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid">-</div>
			<div class="layui-input-inline" style="width: 200px;">
				<input type="text" class="layui-input" name="latitude" value="${hostItem.latitude}" placeholder="请输入纬度(90到-90)" autocomplete="off" class="layui-input">
			</div>
			<div class="layui-form-mid">
				<a href="https://lbs.amap.com/console/show/picker" target="_blank">查看经纬度</a>
			</div>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;交通数目</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="trafficNumber" value="${hostItem.trafficNumber}" placeholder="请输入交通数目" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;交通描述</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="trafficDesc" id="trafficDesc" placeholder="请输入交通描述">${hostItem.trafficDesc}</textarea>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;教育数目</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="teachNumber" value="${hostItem.teachNumber}" placeholder="请输入教育数目" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;教育描述</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="teachDesc" id="teachDesc" placeholder="请输入教育描述">${hostItem.teachDesc}</textarea>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;医疗数目</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="medicalNumber" value="${hostItem.medicalNumber}" placeholder="请输入医疗数目" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;医疗描述</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="medicalDesc" id="medicalDesc" placeholder="请输入医疗描述">${hostItem.medicalDesc}</textarea>
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;商业数目</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="businessNumber" value="${hostItem.businessNumber}" placeholder="请输入商业数目" autocomplete="off" />
		</div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red"></span>&nbsp;&nbsp;商业描述</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="businessDesc" id="businessDesc" placeholder="请输入商业描述">${hostItem.businessDesc}</textarea>
		</div>
	</div>

	<div class="layui-form-item layui-row layui-col-xs12">
		<label class="layui-form-label">
			<span class="red">*</span>&nbsp;&nbsp;序号</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="sort" value="${hostItem.sort}" placeholder="请输入序号" lay-verify="required" autocomplete="off" /></div>
	</div>
	<div class="layui-form-item layui-row layui-col-xs12">
		<div class="layui-input-block">
			<button class="layui-btn layui-btn-sm" lay-submit="" lay-filter="submitBtn">确定</button>
			<button type="reset" class="layui-btn layui-btn-sm layui-btn-primary cancel">取消</button></div>
	</div>
</form>
<script type="text/javascript" src="${s.base}/js/layui/layui.js"></script>
<script type="text/javascript" src="${s.base}/js/base/base.js"></script>
<script type="text/javascript" src="${s.base}/lib/KnifeZ/ace/ace.js"  charset="utf-8"></script>
<script type="text/javascript">
	layui.use(['form', 'jquery', 'baseUtil','dialogUtil','upload','pageUtil','fileUtil','laydate','richTxtUtil'],
    function() {
        var form = layui.form,
            $ = layui.jquery,
            fileUtil = layui.fileUtil,
            upload = layui.upload,
            dialogUtil = layui.dialogUtil,
            richTxtUtil = layui.richTxtUtil,
            baseUtil = layui.baseUtil,
            laydate = layui.laydate,
            pageUtil = layui.pageUtil;
		var shareType='${hostItem.shareType}';
        var images='${hostItem.images}';
		if(images!=null&&images!=""){
		    var imageList=images.split(",");
		    for(var i=0;i<imageList.length;i++){
                var str='<div class="xyg-upload-item">'+
                    '<img src="'+imageList[i]+'" />'+
                    '<div class="xyg-upload-item-btn">'+
                    '<span class="xyg-upload-item-btn-show" data-url="'+imageList[i]+'">预览</span>'+
                    '<span class="xyg-upload-item-btn-right">删除</span>'+
                    '</div>'+
                    '</div>';
                $('#imageContent').append(str);
			}
		}

        laydate.render({
            elem: '#openTime', //指定元素
            type: 'date'
        });

		// 价格修改导致的总价变更
        $("#price").bind('blur',function () {
            var price = $("#price").val();
            var minApartmentArea = $("#minApartmentArea").val();
            var maxApartmentArea = $("#maxApartmentArea").val();
            if (price != null && price != "" && minApartmentArea != null && minApartmentArea != "" && maxApartmentArea != null && maxApartmentArea != "") {
                $("#allPrice").val(Math.round(price*minApartmentArea/10000));
			}
        });
        $("#minApartmentArea").bind('blur',function () {
            var price = $("#price").val();
            var minApartmentArea = $("#minApartmentArea").val();
            var maxApartmentArea = $("#maxApartmentArea").val();
            if (price != null && price != "" && minApartmentArea != null && minApartmentArea != "" && maxApartmentArea != null && maxApartmentArea != "") {
                $("#allPrice").val(Math.round(price*minApartmentArea/10000));
            }
        });
        $("#maxApartmentArea").bind('blur',function () {
            var price = $("#price").val();
            var minApartmentArea = $("#minApartmentArea").val();
            var maxApartmentArea = $("#maxApartmentArea").val();
            if (price != null && price != "" && minApartmentArea != null && minApartmentArea != "" && maxApartmentArea != null && maxApartmentArea != "") {
                $("#allPrice").val(Math.round(price*minApartmentArea/10000));
            }
        });

        $("#areaName").bind('click',function () {
            dialogUtil.popUpSingleSelect("地址选择器","/hostArea/dTreeList?areaIds=${areaIds}",function(id,name,layer,index){
                debugger
                $("#areaId").val(id);
                $("#areaName").val(name);
            });
        });

        $(document).on('click','.xyg-upload-item .xyg-upload-item-btn-show',function(){
            fileUtil.imageSingleShow($(this).attr("data-url"));
        });
        $(document).on('click','.xyg-upload-item .xyg-upload-item-btn-right',function(){
            var obj=$(this);
            dialogUtil.confirm("确定删除图片吗？",function () {
                obj.parent().parent().remove();
            });
        });

        //多图片上传
        upload.render({
            elem: '#image'
            , url: '/sysFile/singleFile' //上传接口
            , data:  {catalog: "host/item", requestFileType:"1",isSave:"2"}
            , done: function (result) {
                if (0 == result.code) {
                    var str='<div class="xyg-upload-item">'+
                        '<img src="'+result.data+'" />'+
                        '<div class="xyg-upload-item-btn">'+
                        '<span class="xyg-upload-item-btn-show" data-url="'+result.data+'">预览</span>'+
                        '<span class="xyg-upload-item-btn-right">删除</span>'+
                        '</div>'+
                        '</div>';
                    $('#imageContent').append(str);
                } else {
                    dialogUtil.msg(result.msg);
                }
            }
            ,multiple: true
            ,before: function(obj){

            }

        });
        //单图片上传
        fileUtil.uploadImageNoSave('images',"host/item","${hostItem.images}");
        //单图片上传
        fileUtil.uploadImageNoSave('coverImage',"host/item","${hostItem.coverImage}");

        //KnifeZ富文本
        var index=richTxtUtil.layeditKnifezBuild("content",300);

        var trafficDesc=richTxtUtil.layeditKnifezBuild("trafficDesc",300);
        var teachDesc=richTxtUtil.layeditKnifezBuild("teachDesc",300);
        var medicalDesc=richTxtUtil.layeditKnifezBuild("medicalDesc",300);
        var businessDesc=richTxtUtil.layeditKnifezBuild("businessDesc",300);

        pageUtil.initDictByUrl("/hostType/acceptSelect","host_host_type",
            function(dictDataurl) {
                pageUtil.initDict("host_share_type,host_hot_sale_state",
                    function(dictData) {
                        pageUtil.showDict($("#shareType"), pageUtil.aceeptDictContentList(dictData, "host_share_type"), "", '${hostItem.shareType}');
                        pageUtil.showDict($("#hotSaleState"), pageUtil.aceeptDictContentList(dictData, "host_hot_sale_state"), "", '${hostItem.hotSaleState}');
                    });
                pageUtil.showDict($("#hostType"), pageUtil.aceeptDictContentList(dictDataurl, "host_host_type"), "", '${hostItem.host_host_type}');
            });
        form.on('submit(submitBtn)',
            function(data) {
            	var images="";
                $("#imageContent .xyg-upload-item .xyg-upload-item-btn-show").each(function (index,obj) {
                    if(images==null||images==""){
                        images=$(obj).attr("data-url");
					}else{
                        images+=","+$(obj).attr("data-url");
					}
                });
                data.field.images=images;
                data.field.content=richTxtUtil.layeditBuildContent(index);

                data.field.trafficDesc=richTxtUtil.layeditBuildContent(trafficDesc);
                data.field.teachDesc=richTxtUtil.layeditBuildContent(teachDesc);
                data.field.medicalDesc=richTxtUtil.layeditBuildContent(medicalDesc);
                data.field.businessDesc=richTxtUtil.layeditBuildContent(businessDesc);

                baseUtil.postMethodResult("/hostItem/addOrUpdate", data.field,
                    function(result) {
                        parent.location.reload();
                    });
                return false;
            });
    });</script>
</body>

</html>